#include <iostream>
#include <string>

using namespace std;

//复数类
class Complex
{
private:
    double real;//实部
    double imag;//虚部
public:
    Complex() : real(0) , imag(0)
    {
    }
    //构造
    Complex(double real,double imag)
        : real(real),imag(imag)
    {

    }
    ~Complex(){}

public:
    //显示
    void show()
    {
        cout << "实部" << real << "虚部" << imag << endl;
    }

public:
    //运算符重载结果 = L.operator#( R )eW   L + R
    const Complex operator+(Complex R) const
    {
        Complex x;
        x.imag = this->imag + R.imag;
        x.real = this->real + R.real;
        return x;
    }

    //运算符重载结果 = L.operator#( R )eW   L - R
    const Complex operator-(Complex R) const
    {
        Complex x;
        x.imag = this->imag - R.imag;
        x.real = this->real - R.real;
        return x;
    }

    // //运算符重载结果 = L.operator#( R )eW   L * R
    // const Complex operator*(Complex R) const
    // {
    //     Complex x;
    //     x.imag = this->imag * R.imag;
    //     x.real = this->real * R.real;
    //     return x;
    // }

    friend const Complex operator*(Complex L,Complex R);
};

const Complex operator*(Complex L,Complex R)
{
    Complex x;
    x.imag = L.imag * R.imag;
    x.real = L.real * L.real;
    return x;
}

int main(int argc, char const *argv[])
{
    Complex F1(10,30);
    Complex F2(10,30);
    Complex F3(10,30);

    //加法
    F3 = F1 + F2;
    F3.show();

    //减法
    F3 = F1 - F2;
    F3.show();

    //乘法
    F3 = F1 * F2;
    F3.show();

    return 0;
}
